home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / OSA.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  53.4 KB  |  1,456 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OSA.p
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1992-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT OSA;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __OSA__}
  28. {$SETC __OSA__ := 1}
  29.  
  30. {$I+}
  31. {$SETC OSAIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __ERRORS__}
  35. {$I Errors.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __APPLEEVENTS__}
  38. {$I AppleEvents.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __AEOBJECTS__}
  41. {$I AEObjects.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __COMPONENTS__}
  44. {$I Components.p}
  45. {$ENDC}
  46.  
  47.  
  48. {$PUSH}
  49. {$ALIGN MAC68K}
  50. {$LibExport+}
  51.  
  52. {*************************************************************************
  53.     Types and Constants
  54. *************************************************************************}
  55.  
  56. {    The componenent manager type code for components that
  57.         support the OSA interface defined here. }
  58. { 0x6f736120 }
  59.  
  60. CONST
  61.     kOSAComponentType            = 'osa ';
  62.  
  63. { 0x73637074 }
  64.     kOSAGenericScriptingComponentSubtype = 'scpt';
  65.  
  66. {    Type of script document files.    }
  67. { 0x6f736173 }
  68.     kOSAFileType                = 'osas';
  69.  
  70. {
  71.         Suite and event code of the RecordedText event. 
  72.         (See OSAStartRecording, below.)
  73.     }
  74. { 0x61736372 }
  75.     kOSASuite                    = 'ascr';
  76.  
  77. { 0x72656364 }
  78.     kOSARecordedText            = 'recd';
  79.  
  80. { Selector returns boolean }
  81. { 0x6d6f6469 }
  82.     kOSAScriptIsModified        = 'modi';
  83.  
  84. { Selector returns boolean }
  85. { 0x63736372 }
  86.     kOSAScriptIsTypeCompiledScript = 'cscr';
  87.  
  88. { Selector returns boolean }
  89. { 0x76616c75 }
  90.     kOSAScriptIsTypeScriptValue    = 'valu';
  91.  
  92. { Selector returns boolean }
  93. { 0x636e7478 }
  94.     kOSAScriptIsTypeScriptContext = 'cntx';
  95.  
  96. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  97. { 0x62657374 }
  98.     kOSAScriptBestType            = 'best';
  99.  
  100. {
  101.         This selector is used to determine whether a script has source 
  102.         associated with it that when given to OSAGetSource, the call will not
  103.         fail.  The selector returns a boolean.
  104.     }
  105. { 0x67737263 }
  106.     kOSACanGetSource            = 'gsrc';
  107.  
  108.  
  109.     typeOSADialectInfo            = 'difo';                        {   0x6469666f    }
  110.     keyOSADialectName            = 'dnam';                        {   0x646e616d    }
  111.     keyOSADialectCode            = 'dcod';                        {   0x64636f64    }
  112.     keyOSADialectLangCode        = 'dlcd';                        {   0x646c6364    }
  113.     keyOSADialectScriptCode        = 'dscd';                        {   0x64736364    }
  114.  
  115.  
  116. TYPE
  117.     OSAError                            = ComponentResult;
  118. { Under the Open Scripting Architecture all error results are longs }
  119.     OSAID                                = LONGINT;
  120. {
  121.         OSAIDs allow transparent manipulation of scripts associated with
  122.          various scripting systems.
  123.     }
  124.  
  125. CONST
  126.     kOSANullScript                = 0;
  127.  
  128. { No -script constant. }
  129.     kOSANullMode                = 0;                            {  sounds better  }
  130.     kOSAModeNull                = 0;                            {  tastes consistent  }
  131.  
  132. {
  133.         Some routines take flags that control their execution.  This constant
  134.         declares default mode settings are used.
  135.     }
  136.  
  137. TYPE
  138.     OSACreateAppleEventProcPtr = ProcPtr;  { FUNCTION OSACreateAppleEvent(theAEEventClass: AEEventClass; theAEEventID: AEEventID; (CONST)VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT): OSErr; }
  139.  
  140.     OSASendProcPtr = ProcPtr;  { FUNCTION OSASend((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT): OSErr; }
  141.  
  142.     OSACreateAppleEventUPP = UniversalProcPtr;
  143.     OSASendUPP = UniversalProcPtr;
  144.  
  145. CONST
  146.     uppOSACreateAppleEventProcInfo = $000FEFE0;
  147.     uppOSASendProcInfo = $003FEFE0;
  148.  
  149. FUNCTION NewOSACreateAppleEventProc(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  150.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  151.     INLINE $2E9F;
  152.     {$ENDC}
  153.  
  154. FUNCTION NewOSASendProc(userRoutine: OSASendProcPtr): OSASendUPP;
  155.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  156.     INLINE $2E9F;
  157.     {$ENDC}
  158.  
  159. FUNCTION CallOSACreateAppleEventProc(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): OSErr;
  160.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  161.     INLINE $205F, $4E90;
  162.     {$ENDC}
  163.  
  164. FUNCTION CallOSASendProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): OSErr;
  165.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  166.     INLINE $205F, $4E90;
  167.     {$ENDC}
  168. {*************************************************************************
  169.     Standard Script Errors
  170. **************************************************************************
  171.     It is recommended that scripting components use the following set of error
  172.     codes to signal failure when applicable.  This enables applications that
  173.     use the OSA API to deal with some class of script errors in a less than 
  174.     ad hoc manner.  Scripting components are of course encouraged to return
  175.     component-specific errors when these don't apply.
  176. *************************************************************************}
  177. {        Dynamic errors:
  178.  
  179.     These errors result from data-dependent conditions and are typically
  180.     signaled at runtime.
  181. }
  182. {
  183.         Signaled when a value can't be coerced to the desired type. Similar
  184.           to errOSATypeError except results from coercion.
  185.     }
  186.  
  187. CONST
  188.     errOSACantCoerce            = -1700;
  189.  
  190. { Signaled when an object is not found in a container }
  191.     errOSACantAccess            = -1728;
  192.  
  193. {
  194.         Signaled when an object cannot be set in a container.  Same as 
  195.           AERegistry error errAEWriteDenied.
  196.     }
  197.     errOSACantAssign            = -10006;
  198.  
  199. {
  200.         Signaled by user scripts or applications when no actual error code
  201.           is to be returned.  Simply means "an error has occurred".  Most useful
  202.           in conjunction with an error message from the application.
  203.     }
  204.     errOSAGeneralError            = -2700;
  205.  
  206. { Signaled when there is an attempt to divide by zero }
  207.     errOSADivideByZero            = -2701;
  208.  
  209. { Signaled when integer or real value is too large to be represented }
  210.     errOSANumericOverflow        = -2702;
  211.  
  212. {
  213.         Signaled when application can't be launched or when it is remote and
  214.           program linking is not enabled.
  215.     }
  216.     errOSACantLaunch            = -2703;
  217.  
  218. { Signaled when an application can't respond to AppleEvents }
  219.     errOSAAppNotHighLevelEventAware = -2704;
  220.  
  221. { Signaled when an application's terminology resource is not readable }
  222.     errOSACorruptTerminology    = -2705;
  223.  
  224. { Signaled when the runtime stack overflows }
  225.     errOSAStackOverflow            = -2706;
  226.  
  227. { Signaled when a runtime internal data structure overflows }
  228.     errOSAInternalTableOverflow    = -2707;
  229.  
  230. {
  231.         Signaled when an intrinsic limitation is exceeded for the size of 
  232.           a value or data structure.
  233.     }
  234.     errOSADataBlockTooLarge        = -2708;
  235.  
  236.     errOSACantGetTerminology    = -2709;
  237.  
  238.     errOSACantCreate            = -2710;
  239.  
  240. {        Component-specific dynamic script errors:
  241.  
  242.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  243.     (Note that error codes from different scripting components in this range will
  244.     overlap.)
  245. }
  246. {        Static errors:
  247.  
  248.     These errors comprise what are commonly thought of as parse and compile-
  249.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  250.     of these may also occur at runtime.
  251. }
  252.  
  253. { Signaled when data was not the right type and coercion is not allowed }
  254.     errOSATypeError                = -1703;
  255.  
  256. { Signaled when a message was sent to an object that didn't handle it }
  257.     OSAMessageNotUnderstood        = -1708;
  258.  
  259. {
  260.         Signaled when a function to be returned doesn't exist.  (Probably only
  261.           useful in languages with first-class functions that distinguish between
  262.           functions and other values (two name spaces). This is different from
  263.           errOSAMessageNotUnderstood, which may be signaled when the method is
  264.           invoked.
  265.     }
  266.     OSAUndefinedHandler            = -1717;
  267.  
  268. { Signaled when a container can never have the requested object }
  269.     OSAIllegalAccess            = -1723;
  270.  
  271. { Signaled when index was out of range. Specialization of errOSACantAccess. }
  272.     OSAIllegalIndex                = -1719;
  273.  
  274. { Signaled when a range is screwy. Specialization of errOSACantAccess. }
  275.     OSAIllegalRange                = -1720;
  276.  
  277. {
  278.         Signaled when an object can never be set in a container.  Same as 
  279.           AERegistry error errAENotModifiable.
  280.     }
  281.     OSAIllegalAssign            = -10003;
  282.  
  283. {
  284.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  285.          "<this> can't go after <that>").
  286.     }
  287.     OSASyntaxError                = -2740;
  288.  
  289. {
  290.         Signaled when another form of syntax was expected. (e.g. "expected
  291.           a <type> but found <this>").
  292.     }
  293.     OSASyntaxTypeError            = -2741;
  294.  
  295. { Signaled when a name or number is too long to be parsed }
  296.     OSATokenTooLong                = -2742;
  297.  
  298. {
  299.         Signaled when a parameter is missing for a function invocation.  Note
  300.           that in some languages, this error may occur at runtime.
  301.     }
  302.     OSAMissingParameter            = -1701;
  303.  
  304. {
  305.         Signaled when function is called with the wrong number of parameters,
  306.           or a parameter pattern cannot be matched.
  307.     }
  308.     OSAParameterMismatch        = -1721;
  309.  
  310. {
  311.         Signaled when a formal parameter, local variable, or instance variable
  312.           is specified more than once.
  313.     }
  314.     OSADuplicateParameter        = -2750;
  315.  
  316. {
  317.         Signaled when a formal parameter, local variable, or instance variable
  318.           is specified more than once.
  319.     }
  320.     OSADuplicateProperty        = -2751;
  321.  
  322. {
  323.         Signaled when more than one handler is defined with the same name in 
  324.           a scope where the language doesn't allow it.
  325.     }
  326.     OSADuplicateHandler            = -2752;
  327.  
  328. { Signaled when a variable is accessed that has no value }
  329.     OSAUndefinedVariable        = -2753;
  330.  
  331. {
  332.         Signaled when a variable is declared inconsistently in the same scope,
  333.           such as both local and global.
  334.     }
  335.     OSAInconsistentDeclarations    = -2754;
  336.  
  337. {
  338.         Signaled when illegal control flow occurs in an application (no catcher
  339.           for throw, non-lexical loop exit, etc.).
  340.     }
  341.     OSAControlFlowError            = -2755;
  342.  
  343. {        Component-specific static script errors:
  344.  
  345.     The range -2760 thru -2779 is reserved for component-specific parsing and
  346.     compile-time errors. (Note that error codes from different scripting
  347.     components in this range will overlap.)
  348. }
  349. {        Dialect-specific script errors:
  350.  
  351.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  352.     scripting components that support dialects. (Note that error codes from
  353.     different scripting components in this range will overlap, as well as error
  354.     codes from different dialects in the same scripting component.)
  355. }
  356. {*************************************************************************
  357.     OSA Interface Descriptions
  358. **************************************************************************
  359.     The OSA Interface is broken down into a required interface, and several
  360.     optional interfaces to support additional functionality.  A given scripting
  361.     component may choose to support only some of the optional interfaces in
  362.     addition to the basic interface.  The OSA Component Flags may be used to 
  363.     query the Component Manager to find a scripting component with a particular
  364.     capability, or determine if a particular scripting component supports a 
  365.     particular capability.
  366. *************************************************************************}
  367. { OSA Component Flags: }
  368.     kOSASupportsCompiling        = $0002;
  369.     kOSASupportsGetSource        = $0004;
  370.     kOSASupportsAECoercion        = $0008;
  371.     kOSASupportsAESending        = $0010;
  372.     kOSASupportsRecording        = $0020;
  373.     kOSASupportsConvenience        = $0040;
  374.     kOSASupportsDialects        = $0080;
  375.     kOSASupportsEventHandling    = $0100;
  376.  
  377. { Component Selectors: }
  378.     kOSASelectLoad                = $0001;
  379.     kOSASelectStore                = $0002;
  380.     kOSASelectExecute            = $0003;
  381.     kOSASelectDisplay            = $0004;
  382.     kOSASelectScriptError        = $0005;
  383.     kOSASelectDispose            = $0006;
  384.     kOSASelectSetScriptInfo        = $0007;
  385.     kOSASelectGetScriptInfo        = $0008;
  386.     kOSASelectSetActiveProc        = $0009;
  387.     kOSASelectGetActiveProc        = $000A;
  388.  
  389. { Compiling: }
  390.     kOSASelectScriptingComponentName = $0102;
  391.     kOSASelectCompile            = $0103;
  392.     kOSASelectCopyID            = $0104;
  393.  
  394. { GetSource: }
  395.     kOSASelectGetSource            = $0201;
  396.  
  397. { AECoercion: }
  398.     kOSASelectCoerceFromDesc    = $0301;
  399.     kOSASelectCoerceToDesc        = $0302;
  400.  
  401. { AESending: }
  402.     kOSASelectSetSendProc        = $0401;
  403.     kOSASelectGetSendProc        = $0402;
  404.     kOSASelectSetCreateProc        = $0403;
  405.     kOSASelectGetCreateProc        = $0404;
  406.     kOSASelectSetDefaultTarget    = $0405;
  407.  
  408. { Recording: }
  409.     kOSASelectStartRecording    = $0501;
  410.     kOSASelectStopRecording        = $0502;
  411.  
  412. { Convenience: }
  413.     kOSASelectLoadExecute        = $0601;
  414.     kOSASelectCompileExecute    = $0602;
  415.     kOSASelectDoScript            = $0603;
  416.  
  417. { Dialects: }
  418.     kOSASelectSetCurrentDialect    = $0701;
  419.     kOSASelectGetCurrentDialect    = $0702;
  420.     kOSASelectAvailableDialects    = $0703;
  421.     kOSASelectGetDialectInfo    = $0704;
  422.     kOSASelectAvailableDialectCodeList = $0705;
  423.  
  424. { Event Handling: }
  425.     kOSASelectSetResumeDispatchProc = $0801;
  426.     kOSASelectGetResumeDispatchProc = $0802;
  427.     kOSASelectExecuteEvent        = $0803;
  428.     kOSASelectDoEvent            = $0804;
  429.     kOSASelectMakeContext        = $0805;
  430.  
  431.  
  432. { scripting component specific selectors are added beginning with this value  }
  433.     kOSASelectComponentSpecificStart = $1001;
  434.  
  435.  
  436. {        Mode Flags:
  437.  
  438.     Warning: These should not conflict with the AESend mode flags in
  439.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  440. }
  441.  
  442. {
  443.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  444.           instruct the scripting component to not retain the "source" of an
  445.           expression.  This will cause the OSAGetSource call to return the error
  446.           errOSASourceNotAvailable if used.  However, some scripting components
  447.           may not retain the source anyway.  This is mainly used when either space
  448.           efficiency is desired, or a script is to be "locked" so that its
  449.           implementation may not be viewed.
  450.     }
  451.     kOSAModePreventGetSource    = $00000001;
  452.  
  453. {
  454.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  455.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  456.           indicate whether or not the script may interact with the user, switch
  457.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  458.           corresponding AESend mode supplied.
  459.     }
  460.     kOSAModeNeverInteract        = $00000010;
  461.     kOSAModeCanInteract            = $00000020;
  462.     kOSAModeAlwaysInteract        = $00000030;
  463.     kOSAModeDontReconnect        = $00000080;
  464.  
  465. {
  466.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  467.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  468.           indicate whether or not AppleEvents should be sent with the
  469.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  470.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  471.           provide a more convenient default, i.e. not supplying any mode
  472.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  473.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  474.           without kAECanSwitchLayer.
  475.     }
  476.     kOSAModeCantSwitchLayer        = $00000040;
  477.  
  478. {
  479.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  480.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  481.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  482.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  483.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  484.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  485.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  486.           cause AESend to be called without kAEDontRecord.
  487.     }
  488.     kOSAModeDoRecord            = $00001000;
  489.  
  490. {
  491.         This is a mode flag for OSACompile that indicates that a context should
  492.           be created as the result of compilation. All handler definitions are
  493.           inserted into the new context, and variables are initialized by
  494.           evaluating their initial values in a null context (i.e. they must be
  495.           constant expressions).
  496.     }
  497.     kOSAModeCompileIntoContext    = $00000002;
  498.  
  499. {
  500.         This is a mode flag for OSACompile that indicates that the previous
  501.           script ID (input to OSACompile) should be augmented with any new
  502.           definitions in the sourceData rather than replaced with a new script.
  503.           This means that the previous script ID must designate a context.
  504.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  505.           to be implicitly used, causing any new definitions to be initialized
  506.           in a null context.
  507.     }
  508.     kOSAModeAugmentContext        = $00000004;
  509.  
  510. {
  511.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  512.           that output only need be human-readable, not re-compilable by OSACompile.
  513.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  514.           off of string values, long lists may have elipses, etc.
  515.     }
  516.     kOSAModeDisplayForHumans    = $00000008;
  517.  
  518. {
  519.         This mode flag may be passed to OSAStore in the case where the scriptID
  520.           is a context.  This causes the context to be saved, but not the context's
  521.           parent context.  When the stored context is loaded back in, the parent
  522.           will be kOSANullScript.
  523.     }
  524.     kOSAModeDontStoreParent        = $00010000;
  525.  
  526. {
  527.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  528.           be dispatched to the direct object of the event. The direct object (or
  529.           subject attribute if the direct object is a non-object specifier) will
  530.           be resolved, and the resulting script object will be the recipient of
  531.           the message. The context argument to OSAExecuteEvent will serve as the
  532.           root of the lookup/resolution process.
  533.     }
  534.     kOSAModeDispatchToDirectObject = $00020000;
  535.  
  536. {
  537.         This mode flag may be passed to OSAExecuteEvent to indicate that
  538.           components do not have to get the data of object specifier arguments.
  539.     }
  540.     kOSAModeDontGetDataForArguments = $00040000;
  541.  
  542. {*************************************************************************
  543.     OSA Basic Scripting Interface
  544. **************************************************************************
  545.     Scripting components must at least support the Basic Scripting interface.
  546. *************************************************************************}
  547. {        Loading and Storing Scripts:
  548.  
  549.     These routines allow scripts to be loaded and stored in their internal
  550.     (possibly compiled, non-text) representation.
  551. }
  552.  
  553. { Resource type for scripts }
  554.     kOSAScriptResourceType        = 'scpt';
  555.  
  556. {
  557.         Default type given to OSAStore which creates "generic" loadable script
  558.           data descriptors.
  559.     }
  560.     typeOSAGenericStorage        = 'scpt';
  561.  
  562. FUNCTION OSALoad(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  563.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  564.     INLINE $2F3C, $000C, $0001, $7000, $A82A;
  565.     {$ENDC}
  566. {
  567.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  568.     
  569.         Errors:
  570.             badComponentInstance        invalid scripting component instance
  571.             errOSASystemError
  572.             errOSABadStorageType:        scriptData not for this scripting component
  573.             errOSACorruptData:            data seems to be corrupt
  574.             errOSADataFormatObsolete    script data format is no longer supported
  575.             errOSADataFormatTooNew        script data format is from a newer version
  576.         
  577.         ModeFlags:
  578.             kOSAModePreventGetSource
  579.     }
  580. FUNCTION OSAStore(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingScriptData: AEDesc): OSAError;
  581.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  582.     INLINE $2F3C, $0010, $0002, $7000, $A82A;
  583.     {$ENDC}
  584. {
  585.         OSAComponentFunctionInline(kOSASelectStore, 16);
  586.     
  587.         Errors:
  588.             badComponentInstance    invalid scripting component instance
  589.             errOSASystemError
  590.             errOSAInvalidID
  591.             errOSABadStorageType:    desiredType not for this scripting component
  592.         
  593.         ModeFlags:
  594.             kOSAModePreventGetSource
  595.             kOSAModeDontStoreParent
  596.     }
  597. { Executing Scripts: }
  598. FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  599.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  600.     INLINE $2F3C, $0010, $0003, $7000, $A82A;
  601.     {$ENDC}
  602. {
  603.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  604.         This call runs a script.  The contextID represents the environment
  605.         with which global variables in the script are resolved.  The constant
  606.         kOSANullScript may be used for the contextID if the application wishes
  607.         to not deal with context directly (a default one is associated with each
  608.         scripting component instance).  The resultingScriptValueID is the 
  609.         result of evaluation, and contains a value which may be displayed using
  610.         the OSAGetSource call.  The modeFlags convey scripting component
  611.         specific information.
  612.     
  613.         Errors:
  614.             badComponentInstance    invalid scripting component instance
  615.             errOSASystemError
  616.             errOSAInvalidID
  617.             errOSAScriptError:        the executing script got an error
  618.     
  619.         ModeFlags:
  620.             kOSAModeNeverInteract
  621.             kOSAModeCanInteract
  622.             kOSAModeAlwaysInteract
  623.             kOSAModeCantSwitchLayer
  624.             kOSAModeDontReconnect
  625.             kOSAModeDoRecord
  626.     }
  627. { Displaying results: }
  628. FUNCTION OSADisplay(scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  629.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  630.     INLINE $2F3C, $0010, $0004, $7000, $A82A;
  631.     {$ENDC}
  632. {
  633.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  634.         This call is used to convert results (script value IDs) into displayable
  635.         text. The desiredType should be at least typeChar, and modeFlags are
  636.         scripting system specific flags to control the formatting of the
  637.         resulting text. This call differs from OSAGetSource in that (1) it
  638.         always produces at least typeChar, (2) is only works on script values,
  639.         (3) it may display it's output in non-compilable form (e.g. without
  640.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  641.         (4) it is required by the basic scripting interface.
  642.     
  643.         Errors:
  644.             badComponentInstance    invalid scripting component instance
  645.             errOSASystemError
  646.             errOSAInvalidID
  647.             errAECoercionFail:        desiredType not supported by scripting component
  648.     
  649.         ModeFlags:
  650.             kOSAModeDisplayForHumans
  651.     }
  652. { Getting Error Information: }
  653. FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc): OSAError;
  654.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  655.     INLINE $2F3C, $000C, $0005, $7000, $A82A;
  656.     {$ENDC}
  657. {
  658.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  659.         Whenever script execution returns errOSAExecutionError, this routine
  660.         may be used to get information about that error.  The selector describes
  661.         the type of information desired about the error (various selectors are
  662.         listed below).  The desiredType indicates the data type of the result
  663.         desired for that selector.
  664.     
  665.         Errors:
  666.             badComponentInstance    invalid scripting component instance
  667.             errOSASystemError
  668.             errOSABadSelector:        selector not supported by scripting component
  669.             errAECoercionFail:        desiredType not supported by scripting component
  670.     }
  671. { OSAScriptError selectors: }
  672. {
  673.         This selector is used to determine the error number of a script error.
  674.         These error numbers may be either system error numbers, or error numbers
  675.         that are scripting component specific.
  676.         Required desiredTypes:    
  677.               typeShortInteger
  678.     }
  679.  
  680. CONST
  681.     kOSAErrorNumber                = 'errn';
  682.  
  683. {
  684.         This selector is used to determine the full error message associated
  685.         with the error number.  It should include the name of the application
  686.         which caused the error, as well as the specific error that occurred.
  687.         This selector is sufficient for simple error reporting (but see
  688.         kOSAErrorBriefMessage, below).
  689.         Required desiredTypes:
  690.             typeChar                    error message string
  691.     }
  692.     kOSAErrorMessage            = 'errs';
  693.  
  694. {
  695.         This selector is used to determine a brief error message associated with
  696.         the error number.  This message and should not mention the name of the
  697.         application which caused the error, any partial results or offending
  698.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  699.         kOSAErrorOffendingObject, below).
  700.         Required desiredTypes:
  701.               typeChar                    brief error message string
  702.     }
  703. {  0x65727262  }
  704.     kOSAErrorBriefMessage        = 'errb';
  705.  
  706. {
  707.         This selector is used to determine which application actually got the
  708.         error (if it was the result of an AESend), or the current application
  709.         if ....
  710.         Required desiredTypes:
  711.               typeProcessSerialNumber        PSN of the errant application
  712.               typeChar                    name of the errant application
  713.     }
  714. {  0x65726170  }
  715.     kOSAErrorApp                = 'erap';
  716.  
  717. {
  718.         This selector is used to determine any partial result returned by an 
  719.         operation. If an AESend call failed, but a partial result was returned,
  720.         then the partial result may be returned as an AEDesc.
  721.         Required desiredTypes:
  722.               typeBest                    AEDesc of any partial result
  723.     }
  724. {  0x70746c72   }
  725.     kOSAErrorPartialResult        = 'ptlr';
  726.  
  727. {
  728.         This selector is used to determine any object which caused the error
  729.         that may have been indicated by an application.  The result is an 
  730.         AEDesc.
  731.         Required desiredTypes:
  732.               typeBest                    AEDesc of any offending object
  733.     }
  734. {  0x65726f62   }
  735.     kOSAErrorOffendingObject    = 'erob';
  736.  
  737. {
  738.         This selector is used to determine the type expected by a coercion 
  739.         operation if a type error occurred.
  740.     }
  741. {  0x65727274   }
  742.     kOSAErrorExpectedType        = 'errt';
  743.  
  744. {
  745.         This selector is used to determine the source text range (start and 
  746.         end positions) of where the error occurred.
  747.         Required desiredTypes:
  748.               typeOSAErrorRange
  749.     }
  750. {  0x65726e67  }
  751.     kOSAErrorRange                = 'erng';
  752.  
  753. {
  754.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  755.         of type short.
  756.     }
  757. {  0x65726e67   }
  758.     typeOSAErrorRange            = 'erng';
  759.  
  760. { Field of a typeOSAErrorRange record of typeShortInteger }
  761. {  0x73726373    }
  762.     keyOSASourceStart            = 'srcs';
  763.  
  764. { Field of a typeOSAErrorRange record of typeShortInteger }
  765. {  0x73726365   }
  766.     keyOSASourceEnd                = 'srce';
  767.  
  768. { Disposing Script IDs: }
  769. FUNCTION OSADispose(scriptingComponent: ComponentInstance; scriptID: OSAID): OSAError;
  770.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  771.     INLINE $2F3C, $0004, $0006, $7000, $A82A;
  772.     {$ENDC}
  773. {
  774.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  775.         Disposes a script or context.
  776.     
  777.         Errors:
  778.             badComponentInstance    invalid scripting component instance
  779.             errOSASystemError
  780.             errOSAInvalidID
  781.     }
  782. { Getting and Setting Script Information: }
  783. FUNCTION OSASetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: LONGINT): OSAError;
  784.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  785.     INLINE $2F3C, $000C, $0007, $7000, $A82A;
  786.     {$ENDC}
  787. {
  788.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  789.     
  790.         Errors:
  791.             badComponentInstance    invalid scripting component instance
  792.             errOSASystemError
  793.             errOSAInvalidID
  794.             errOSABadSelector:        selector not supported by scripting component
  795.                                     or selector not for this scriptID
  796.     }
  797. FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; VAR result: LONGINT): OSAError;
  798.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  799.     INLINE $2F3C, $000C, $0008, $7000, $A82A;
  800.     {$ENDC}
  801. {
  802.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  803.     
  804.         Errors:
  805.             badComponentInstance    invalid scripting component instance
  806.             errOSASystemError
  807.             errOSAInvalidID
  808.             errOSABadSelector:        selector not supported by scripting component
  809.                                     or selector not for this scriptID
  810.     }
  811. { Manipulating the ActiveProc:
  812.  
  813.     Scripting systems will supply default values for these procedures if they
  814.     are not set by the client:
  815. }
  816.  
  817. TYPE
  818.     OSAActiveProcPtr = ProcPtr;  { FUNCTION OSAActive(refCon: LONGINT): OSErr; }
  819.  
  820.     OSAActiveUPP = UniversalProcPtr;
  821.  
  822. CONST
  823.     uppOSAActiveProcInfo = $000000E0;
  824.  
  825. FUNCTION NewOSAActiveProc(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  826.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  827.     INLINE $2E9F;
  828.     {$ENDC}
  829.  
  830. FUNCTION CallOSAActiveProc(refCon: LONGINT; userRoutine: OSAActiveUPP): OSErr;
  831.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  832.     INLINE $205F, $4E90;
  833.     {$ENDC}
  834. FUNCTION OSASetActiveProc(scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  835.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  836.     INLINE $2F3C, $0008, $0009, $7000, $A82A;
  837.     {$ENDC}
  838. {
  839.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  840.         If activeProc is nil, the default activeProc is used.
  841.     
  842.         Errors:
  843.             badComponentInstance    invalid scripting component instance
  844.             errOSASystemError
  845.     }
  846. FUNCTION OSAGetActiveProc(scriptingComponent: ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  847.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  848.     INLINE $2F3C, $0008, $000A, $7000, $A82A;
  849.     {$ENDC}
  850. {
  851.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  852.     
  853.         Errors:
  854.             badComponentInstance    invalid scripting component instance
  855.             errOSASystemError
  856.     }
  857. {*************************************************************************
  858.     OSA Optional Compiling Interface
  859. **************************************************************************
  860.     Scripting components that support the Compiling interface have the 
  861.     kOSASupportsCompiling bit set in it's ComponentDescription.
  862. *************************************************************************}
  863. FUNCTION OSAScriptingComponentName(scriptingComponent: ComponentInstance; VAR resultingScriptingComponentName: AEDesc): OSAError;
  864.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  865.     INLINE $2F3C, $0004, $0102, $7000, $A82A;
  866.     {$ENDC}
  867. {
  868.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  869.         Given a scripting component, this routine returns the name of that
  870.         scripting component in a type that is coercable to text (typeChar).
  871.         The generic scripting component returns the name of the default
  872.         scripting component.  This name should be sufficient to convey to the
  873.         user the kind of script (syntax) he is expected to write.
  874.     
  875.         Errors:
  876.             badComponentInstance    invalid scripting component instance
  877.             errOSASystemError
  878.     }
  879. FUNCTION OSACompile(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  880.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  881.     INLINE $2F3C, $000C, $0103, $7000, $A82A;
  882.     {$ENDC}
  883. {
  884.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  885.         Coerces input desc (possibly text) into a script's internal format.
  886.         Once compiled, the script is ready to run.  The modeFlags convey
  887.         scripting component specific information.  The previous script ID
  888.         (result parameter) is made to refer to the newly compiled script,
  889.         unless it was originally kOSANullScript.  In this case a new script
  890.         ID is created and used.
  891.     
  892.         Errors:
  893.             badComponentInstance    invalid scripting component instance
  894.             errOSASystemError
  895.             errAECoercionFail:        sourceData is not compilable
  896.             errOSAScriptError:        sourceData was a bad script (syntax error)
  897.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  898.                                     valid on input
  899.     
  900.         ModeFlags:
  901.             kOSAModePreventGetSource
  902.             kOSAModeCompileIntoContext
  903.             kOSAModeAugmentContext
  904.             kOSAModeNeverInteract
  905.             kOSAModeCanInteract
  906.             kOSAModeAlwaysInteract
  907.             kOSAModeCantSwitchLayer
  908.             kOSAModeDontReconnect
  909.             kOSAModeDoRecord
  910.     }
  911. FUNCTION OSACopyID(scriptingComponent: ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  912.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  913.     INLINE $2F3C, $0008, $0104, $7000, $A82A;
  914.     {$ENDC}
  915. {
  916.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  917.         If toID is a reference to kOSANullScript then it is updated to have a
  918.         new scriptID value.  This call can be used to perform undo or revert
  919.         operations on scripts. 
  920.     
  921.         Errors:
  922.             badComponentInstance    invalid scripting component instance
  923.             errOSASystemError
  924.             errOSAInvalidID
  925.     }
  926. {*************************************************************************
  927.     OSA Optional GetSource Interface
  928. **************************************************************************
  929.     Scripting components that support the GetSource interface have the 
  930.     kOSASupportsGetSource bit set in it's ComponentDescription.
  931. *************************************************************************}
  932. FUNCTION OSAGetSource(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; VAR resultingSourceData: AEDesc): OSAError;
  933.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  934.     INLINE $2F3C, $000C, $0201, $7000, $A82A;
  935.     {$ENDC}
  936. {
  937.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  938.         This routine causes a compiled script to be output in a form (possibly
  939.         text) such that it is suitable to be passed back to OSACompile.
  940.  
  941.         Errors:
  942.             badComponentInstance    invalid scripting component instance
  943.             errOSASystemError
  944.             errOSAInvalidID
  945.             errOSASourceNotAvailable    can't get source for this scriptID
  946.     }
  947. {*************************************************************************
  948.     OSA Optional AECoercion Interface
  949. **************************************************************************
  950.     Scripting components that support the AECoercion interface have the 
  951.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  952. *************************************************************************}
  953. FUNCTION OSACoerceFromDesc(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  954.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  955.     INLINE $2F3C, $000C, $0301, $7000, $A82A;
  956.     {$ENDC}
  957. {
  958.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  959.         This routine causes script data to be coerced into a script value.
  960.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  961.         compiled script ID (mode flags for OSACompile may be used in this case).
  962.         Other scriptData descriptors create script value IDs.
  963.     
  964.         Errors:
  965.             badComponentInstance    invalid scripting component instance
  966.             errOSASystemError
  967.     
  968.         ModeFlags:
  969.             kOSAModePreventGetSource
  970.             kOSAModeCompileIntoContext
  971.             kOSAModeNeverInteract
  972.             kOSAModeCanInteract
  973.             kOSAModeAlwaysInteract
  974.             kOSAModeCantSwitchLayer
  975.             kOSAModeDontReconnect
  976.             kOSAModeDoRecord
  977.     }
  978. FUNCTION OSACoerceToDesc(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR result: AEDesc): OSAError;
  979.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  980.     INLINE $2F3C, $0010, $0302, $7000, $A82A;
  981.     {$ENDC}
  982. {
  983.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  984.         This routine causes a script value to be coerced into any desired form.
  985.         If the scriptID denotes a compiled script, then it may be coerced to 
  986.         typeAppleEvent.
  987.     
  988.         Errors:
  989.             badComponentInstance    invalid scripting component instance
  990.             errOSASystemError
  991.             errOSAInvalidID
  992.     }
  993. {*************************************************************************
  994.     OSA Optional AESending Interface
  995. **************************************************************************
  996.     Scripting components that support the AESending interface have the 
  997.     kOSASupportsAESending bit set in it's ComponentDescription.
  998. *************************************************************************}
  999. {
  1000.     Scripting systems will supply default values for these procedures if they
  1001.     are not set by the client:
  1002. }
  1003. FUNCTION OSASetSendProc(scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  1004.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1005.     INLINE $2F3C, $0008, $0401, $7000, $A82A;
  1006.     {$ENDC}
  1007. {
  1008.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1009.         If sendProc is nil, the default sendProc is used.
  1010.     
  1011.         Errors:
  1012.             badComponentInstance    invalid scripting component instance
  1013.             errOSASystemError
  1014.     }
  1015. FUNCTION OSAGetSendProc(scriptingComponent: ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  1016.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1017.     INLINE $2F3C, $0008, $0402, $7000, $A82A;
  1018.     {$ENDC}
  1019. {
  1020.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1021.     
  1022.         Errors:
  1023.             badComponentInstance    invalid scripting component instance
  1024.             errOSASystemError
  1025.     }
  1026. FUNCTION OSASetCreateProc(scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  1027.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1028.     INLINE $2F3C, $0008, $0403, $7000, $A82A;
  1029.     {$ENDC}
  1030. {
  1031.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1032.         If createProc is nil, the default createProc is used.
  1033.     
  1034.         Errors:
  1035.             badComponentInstance    invalid scripting component instance
  1036.             errOSASystemError
  1037.     }
  1038. FUNCTION OSAGetCreateProc(scriptingComponent: ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1039.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1040.     INLINE $2F3C, $0008, $0404, $7000, $A82A;
  1041.     {$ENDC}
  1042. {
  1043.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1044.     
  1045.         Errors:
  1046.             badComponentInstance    invalid scripting component instance
  1047.             errOSASystemError
  1048.     }
  1049. FUNCTION OSASetDefaultTarget(scriptingComponent: ComponentInstance; {CONST}VAR target: AEAddressDesc): OSAError;
  1050.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1051.     INLINE $2F3C, $0004, $0405, $7000, $A82A;
  1052.     {$ENDC}
  1053. {
  1054.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1055.         This routine sets the default target application for AE sending.
  1056.         It also establishes the default target from which terminologies come.
  1057.         It is effectively like having an AppleScript "tell" statement around
  1058.         the entire program.  If this routine is not called, or if the target 
  1059.         is a null AEDesc, then the current application is the default target.
  1060.     
  1061.         Errors:
  1062.             badComponentInstance    invalid scripting component instance
  1063.             errOSASystemError
  1064.     }
  1065. {*************************************************************************
  1066.     OSA Optional Recording Interface
  1067. **************************************************************************
  1068.     Scripting components that support the Recording interface have the 
  1069.     kOSASupportsRecording bit set in it's ComponentDescription.
  1070. *************************************************************************}
  1071. FUNCTION OSAStartRecording(scriptingComponent: ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1072.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1073.     INLINE $2F3C, $0004, $0501, $7000, $A82A;
  1074.     {$ENDC}
  1075. {
  1076.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1077.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1078.         new script ID is created and returned.  If the current application has
  1079.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1080.         are sent to the application containing the text of each AppleEvent 
  1081.         recorded.
  1082.     
  1083.         Errors:
  1084.             badComponentInstance    invalid scripting component instance
  1085.             errOSASystemError
  1086.             errOSAInvalidID
  1087.             errOSARecordingIsAlreadyOn
  1088.     }
  1089. FUNCTION OSAStopRecording(scriptingComponent: ComponentInstance; compiledScriptID: OSAID): OSAError;
  1090.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1091.     INLINE $2F3C, $0004, $0502, $7000, $A82A;
  1092.     {$ENDC}
  1093. {
  1094.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1095.         If compiledScriptID is not being recorded into or recording is not
  1096.         currently on, no error is returned.
  1097.     
  1098.         Errors:
  1099.             badComponentInstance    invalid scripting component instance
  1100.             errOSASystemError
  1101.             errOSAInvalidID
  1102.     }
  1103. {*************************************************************************
  1104.     OSA Optional Convenience Interface
  1105. **************************************************************************
  1106.     Scripting components that support the Convenience interface have the 
  1107.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1108. *************************************************************************}
  1109. FUNCTION OSALoadExecute(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1110.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1111.     INLINE $2F3C, $0010, $0601, $7000, $A82A;
  1112.     {$ENDC}
  1113. {
  1114.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1115.         This routine is effectively equivalent to calling OSALoad followed by
  1116.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1117.         resulting value ID is retained.
  1118.     
  1119.         Errors:
  1120.             badComponentInstance        invalid scripting component instance
  1121.             errOSASystemError
  1122.             errOSABadStorageType:        scriptData not for this scripting component
  1123.             errOSACorruptData:            data seems to be corrupt
  1124.             errOSADataFormatObsolete    script data format is no longer supported
  1125.             errOSADataFormatTooNew        script data format is from a newer version
  1126.             errOSAInvalidID
  1127.             errOSAScriptError:            the executing script got an error
  1128.     
  1129.         ModeFlags:
  1130.             kOSAModeNeverInteract
  1131.             kOSAModeCanInteract
  1132.             kOSAModeAlwaysInteract
  1133.             kOSAModeCantSwitchLayer
  1134.             kOSAModeDontReconnect
  1135.             kOSAModeDoRecord
  1136.     }
  1137. FUNCTION OSACompileExecute(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1138.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1139.     INLINE $2F3C, $0010, $0602, $7000, $A82A;
  1140.     {$ENDC}
  1141. {
  1142.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1143.         This routine is effectively equivalent to calling OSACompile followed by
  1144.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1145.         resulting value ID is retained.
  1146.     
  1147.         Errors:
  1148.             badComponentInstance    invalid scripting component instance
  1149.             errOSASystemError
  1150.             errAECoercionFail:        sourceData is not compilable
  1151.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1152.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1153.                                     valid on input
  1154.             errOSAScriptError:        the executing script got an error
  1155.     
  1156.         ModeFlags:
  1157.             kOSAModeNeverInteract
  1158.             kOSAModeCanInteract
  1159.             kOSAModeAlwaysInteract
  1160.             kOSAModeCantSwitchLayer
  1161.             kOSAModeDontReconnect
  1162.             kOSAModeDoRecord
  1163.     }
  1164. FUNCTION OSADoScript(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  1165.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1166.     INLINE $2F3C, $0014, $0603, $7000, $A82A;
  1167.     {$ENDC}
  1168. {
  1169.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1170.         This routine is effectively equivalent to calling OSACompile followed by
  1171.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1172.         and the resulting value are is disposed.  Only the resultingText
  1173.         descriptor is retained.  If a script error occur during processing, the 
  1174.         resultingText gets the error message of the error, and errOSAScriptError
  1175.         is returned.  OSAScriptError may still be used to extract more 
  1176.         information about the particular error.
  1177.     
  1178.         Errors:
  1179.             badComponentInstance    invalid scripting component instance
  1180.             errOSASystemError
  1181.             errAECoercionFail:        sourceData is not compilable or 
  1182.                                     desiredType not supported by scripting component
  1183.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1184.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1185.                                     valid on input
  1186.             errOSAScriptError:        the executing script got an error
  1187.     
  1188.         ModeFlags:
  1189.             kOSAModeNeverInteract
  1190.             kOSAModeCanInteract
  1191.             kOSAModeAlwaysInteract
  1192.             kOSAModeCantSwitchLayer
  1193.             kOSAModeDontReconnect
  1194.             kOSAModeDoRecord
  1195.             kOSAModeDisplayForHumans
  1196.     }
  1197. {*************************************************************************
  1198.     OSA Optional Dialects Interface
  1199. **************************************************************************
  1200.     Scripting components that support the Dialects interface have the 
  1201.     kOSASupportsDialects bit set in it's ComponentDescription.
  1202. *************************************************************************}
  1203. {
  1204.     These calls allows an scripting component that supports different dialects
  1205.     to dynamically switch between those dialects.  Although this interface is
  1206.     specified, the particular dialect codes are scripting component dependent.
  1207. }
  1208. FUNCTION OSASetCurrentDialect(scriptingComponent: ComponentInstance; dialectCode: INTEGER): OSAError;
  1209.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1210.     INLINE $2F3C, $0002, $0701, $7000, $A82A;
  1211.     {$ENDC}
  1212. {
  1213.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1214.     
  1215.         Errors:
  1216.             badComponentInstance    invalid scripting component instance
  1217.             errOSASystemError
  1218.             errOSANoSuchDialect:    invalid dialectCode
  1219.     }
  1220. FUNCTION OSAGetCurrentDialect(scriptingComponent: ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1221.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1222.     INLINE $2F3C, $0004, $0702, $7000, $A82A;
  1223.     {$ENDC}
  1224. {
  1225.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1226.     
  1227.         Errors:
  1228.             badComponentInstance    invalid scripting component instance
  1229.             errOSASystemError
  1230.     }
  1231. FUNCTION OSAAvailableDialects(scriptingComponent: ComponentInstance; VAR resultingDialectInfoList: AEDesc): OSAError;
  1232.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1233.     INLINE $2F3C, $0004, $0703, $7000, $A82A;
  1234.     {$ENDC}
  1235. {
  1236.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1237.         This call return an AEList containing information about each of the
  1238.         currently available dialects of a scripting component.  Each item
  1239.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1240.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1241.         keyOSADialectScriptCode.
  1242.     
  1243.         Errors:
  1244.             badComponentInstance    invalid scripting component instance
  1245.             errOSASystemError
  1246.     }
  1247. FUNCTION OSAGetDialectInfo(scriptingComponent: ComponentInstance; dialectCode: INTEGER; selector: OSType; VAR resultingDialectInfo: AEDesc): OSAError;
  1248.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1249.     INLINE $2F3C, $000A, $0704, $7000, $A82A;
  1250.     {$ENDC}
  1251. {
  1252.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1253.         This call gives information about the specified dialect of a scripting
  1254.         component. It returns an AEDesc whose type depends on the selector 
  1255.         specified. Available selectors are the same as the field keys for a
  1256.         dialect info record. The type of AEDesc returned is the same as the 
  1257.         type of the field that has same key as the selector.
  1258.     
  1259.         Errors:
  1260.             badComponentInstance    invalid scripting component instance
  1261.             errOSASystemError
  1262.              errOSABadSelector
  1263.             errOSANoSuchDialect:    invalid dialectCode
  1264.     }
  1265. FUNCTION OSAAvailableDialectCodeList(scriptingComponent: ComponentInstance; VAR resultingDialectCodeList: AEDesc): OSAError;
  1266.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1267.     INLINE $2F3C, $0004, $0705, $7000, $A82A;
  1268.     {$ENDC}
  1269. {
  1270.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1271.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1272.         and  OSAGetDialectInfo to get information on dialects.
  1273.         This call return an AEList containing dialect code for each of the
  1274.         currently available dialects of a scripting component. Each dialect
  1275.         code is a short integer of type typeShortInteger.
  1276.     
  1277.         Errors:
  1278.             badComponentInstance    invalid scripting component instance
  1279.             errOSASystemError
  1280.  
  1281.         Type of a dialect info record containing at least keyOSADialectName
  1282.         and keyOSADialectCode fields.
  1283.  
  1284.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1285.  
  1286.         Field of a typeOSADialectInfo record of typeChar.
  1287.         Field of a typeOSADialectInfo record of typeShortInteger.
  1288.         Field of a typeOSADialectInfo record of typeShortInteger.
  1289.         Field of a typeOSADialectInfo record of typeShortInteger.
  1290.     }
  1291. {*************************************************************************
  1292.     OSA Optional Event Handling Interface
  1293. **************************************************************************
  1294.     Scripting components that support the Event Handling interface have the 
  1295.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1296. *************************************************************************}
  1297. FUNCTION OSASetResumeDispatchProc(scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1298.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1299.     INLINE $2F3C, $0008, $0801, $7000, $A82A;
  1300.     {$ENDC}
  1301. {
  1302.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1303.         This function is used to set the ResumeDispatchProc that will be used
  1304.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1305.         found in the context, or the context event hander "continues" control
  1306.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1307.         may also be passed to this routine indicating that the handler registered
  1308.         in the application with AEInstallEventHandler should be used, or no
  1309.         dispatch should occur, respectively.
  1310.     
  1311.         Errors:
  1312.             badComponentInstance    invalid scripting component instance
  1313.             errOSASystemError
  1314.     }
  1315.  
  1316. CONST
  1317.     kOSAUseStandardDispatch        = $FFFFFFFF;
  1318.  
  1319. {
  1320.         Special ResumeDispatchProc constant which may be passed to 
  1321.         OSASetResumeDispatchProc indicating that the handler registered
  1322.         in the application with AEInstallEventHandler should be used.
  1323.         
  1324.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1325.                 doesn't allow pointer types to be assigned to an enum.  All
  1326.                 constants must be assigned as enums to translate properly to
  1327.                 Pascal.
  1328.     }
  1329.     kOSANoDispatch                = 0;
  1330.  
  1331. {
  1332.         Special ResumeDispatchProc constant which may be passed to 
  1333.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1334.         
  1335.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1336.                 doesn't allow pointer types to be assigned to an enum.  All
  1337.                 constants must be assigned as enums to translate properly to
  1338.                 Pascal.
  1339.     }
  1340.     kOSADontUsePhac                = $0001;
  1341.  
  1342. {
  1343.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1344.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1345.         This causes the standard dispatch to be performed, except the phac
  1346.         handler is not called.  This is useful during tinkerability, when
  1347.         the phac handler is used to lookup a context associated with an event's 
  1348.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1349.         bypass the phac handler would result in an infinite loop.
  1350.     }
  1351. FUNCTION OSAGetResumeDispatchProc(scriptingComponent: ComponentInstance; VAR resumeDispatchProc: AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1352.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1353.     INLINE $2F3C, $0008, $0802, $7000, $A82A;
  1354.     {$ENDC}
  1355. {
  1356.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1357.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1358.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1359.     
  1360.         Errors:
  1361.             badComponentInstance    invalid scripting component instance
  1362.             errOSASystemError
  1363.     }
  1364. FUNCTION OSAExecuteEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1365.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1366.     INLINE $2F3C, $0010, $0803, $7000, $A82A;
  1367.     {$ENDC}
  1368. {
  1369.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1370.         This call is similar to OSAExecute except the initial command to
  1371.         execute comes in the form of an AppleEvent.  If the contextID
  1372.         defines any event handlers for that event, they are used to process
  1373.         the event.  If no event handler can be found in the context
  1374.         errAEEventNotHandled is returned.  If an event handler is found and
  1375.         the hander "continues" control onward, the ResumeDispatchProc
  1376.         (registered with OSASetResumeDispatchProc, above) is called given the
  1377.         AppleEvent.  The result is returned as a scriptValueID.
  1378.     
  1379.         Errors:
  1380.             badComponentInstance    invalid scripting component instance
  1381.             errOSASystemError
  1382.             errOSAInvalidID
  1383.             errOSAScriptError:        the executing script got an error
  1384.             errAEEventNotHandled:    no handler for event in contextID
  1385.     
  1386.         ModeFlags:
  1387.             kOSAModeNeverInteract
  1388.             kOSAModeCanInteract
  1389.             kOSAModeAlwaysInteract
  1390.             kOSAModeCantSwitchLayer
  1391.             kOSAModeDontReconnect
  1392.             kOSAModeDoRecord
  1393.     }
  1394. FUNCTION OSADoEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvent): OSAError;
  1395.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1396.     INLINE $2F3C, $0010, $0804, $7000, $A82A;
  1397.     {$ENDC}
  1398. {
  1399.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1400.         This call is similar to OSADoScript except the initial command to
  1401.         execute comes in the form of an AppleEvent, and the result is an 
  1402.         AppleEvent reply record.  If the contextID defines any event handlers
  1403.         for that event, they are used to process the event.  If no event handler
  1404.         can be found in the context errAEEventNotHandled is returned.  If an
  1405.         event handler is found and the hander "continues" control onward, the
  1406.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1407.         called given the AppleEvent.  The result is returned in the form of an
  1408.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1409.         if the ResumeDispatchProc returns a reply event indicating an error,
  1410.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1411.         should never return errOSAScriptError).  Any error result returned by
  1412.         the ResumeDispatchProc will be returned by OSADoEvent.
  1413.     
  1414.         Errors:
  1415.             badComponentInstance    invalid scripting component instance
  1416.             errOSASystemError
  1417.             errOSAInvalidID
  1418.             errAEEventNotHandled:    no handler for event in contextID
  1419.     
  1420.         ModeFlags:
  1421.             kOSAModeNeverInteract
  1422.             kOSAModeCanInteract
  1423.             kOSAModeAlwaysInteract
  1424.             kOSAModeCantSwitchLayer
  1425.             kOSAModeDontReconnect
  1426.             kOSAModeDoRecord
  1427.     }
  1428. FUNCTION OSAMakeContext(scriptingComponent: ComponentInstance; {CONST}VAR contextName: AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1429.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1430.     INLINE $2F3C, $000C, $0805, $7000, $A82A;
  1431.     {$ENDC}
  1432. {
  1433.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1434.         Makes a new empty context which may be passed to OSAExecute or 
  1435.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1436.         created. If parentContext is kOSANullScript then the resulting context
  1437.         does not inherit bindings from any other context.
  1438.     
  1439.         Errors:
  1440.             badComponentInstance    invalid scripting component instance
  1441.             errOSASystemError
  1442.             errOSAInvalidID
  1443.             errAECoercionFail:        contextName is invalid
  1444.     }
  1445.  
  1446. {$ALIGN RESET}
  1447. {$POP}
  1448.  
  1449. {$SETC UsingIncludes := OSAIncludes}
  1450.  
  1451. {$ENDC} {__OSA__}
  1452.  
  1453. {$IFC NOT UsingIncludes}
  1454.  END.
  1455. {$ENDC}
  1456.